package com.ql.service.cgBingAn.impl;

import com.ql.dao.cgBingAn.CgBingAnMapper;
import com.ql.dao.zydj.ZydjMapper;
import com.ql.pojo.keshi.FangShe;
import com.ql.pojo.menzhen.Fomulary;
import com.ql.pojo.zydj.Zuyuandengji;
import com.ql.service.cgBingAn.CgBingAnService;
import com.ql.utils.PageHelper;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service("cgBingAnService")
public class CgBingAnServiceImpl implements CgBingAnService {
    private static final Logger LOGGER =Logger.getLogger(CgBingAnServiceImpl.class);

    @Resource
    private CgBingAnMapper cgBingAnMapper;

    /*门诊部病案*/
    @Override
    public List<Fomulary> getAllFom(PageHelper ph, String qryYiName, int qryKid, Date yiZhiXingTime,String qryDoc,String qryyiQianMing,int qryUid) {
        List<Fomulary> fomularyList = new ArrayList<>();

        try {
            ph.setTotalCount(cgBingAnMapper.qryCount(qryYiName,qryKid,yiZhiXingTime,qryDoc,qryyiQianMing,qryUid));
            fomularyList = cgBingAnMapper.qryAll((ph.getCurrentPageNo()-1)*ph.getPageSize(),ph.getPageSize(),qryYiName,qryKid,yiZhiXingTime,qryDoc,qryyiQianMing,qryUid);
            if (fomularyList.size()<=0){
                LOGGER.debug("CgBingAnServiceImpl.getAllFom 查询为空！");
            }else {
                LOGGER.debug("CgBingAnServiceImpl.getAllFom 查询成功！");
            }
        } catch (Exception e) {
            LOGGER.error("CgBingAnServiceImpl.getAllFom 异常"+e.getMessage());
        }
        return fomularyList;
    }

    @Override
    public Fomulary getFomById(int id) {
        Fomulary fomulary = null;
        try {
            fomulary = cgBingAnMapper.qryById(id);
            if (null == fomulary){
                LOGGER.debug("CgBingAnServiceImpl.getFomById 查询为空！");
            }else {
                LOGGER.debug("CgBingAnServiceImpl.getFomById 查询成功！");
            }
        } catch (Exception e) {
            LOGGER.error("CgBingAnServiceImpl.getFomById 查询异常！"+e.getMessage());
            fomulary = new Fomulary();
        }
        return fomulary;
    }
    /*---------------------------------住院部病案----------------------------------------------*/
    /*住院部病案*/
    @Override
    public List<Zuyuandengji> getAllzhuyuanBa(int userId, String qryUserName, String qryKeshi, String qryDoc,Date qrycheckInTime, PageHelper ph) {
        List<Zuyuandengji> zuyuandengjiList = new ArrayList<>();

        try {
            ph.setTotalCount(cgBingAnMapper.qryzyCount(userId,qryUserName,qryKeshi,qryDoc));
            zuyuandengjiList = cgBingAnMapper.qryAllzhuyuan((ph.getCurrentPageNo()-1)*ph.getPageSize(),ph.getPageSize(),userId,qryUserName,qryKeshi,qryDoc,qrycheckInTime);
            if (zuyuandengjiList.size()<=0){
                LOGGER.debug("CgBingAnServiceImpl.getAllzhuyuanBa 查询为空！！");
            }else{
                LOGGER.debug("CgBingAnServiceImpl.getAllzhuyuanBa 查询成功！！");
            }
        } catch (Exception e) {
            LOGGER.error("CgBingAnServiceImpl.getAllzhuyuanBa 查询异常！！》》》》"+e.getMessage());
        }
        return zuyuandengjiList;
    }
    @Override
    public Zuyuandengji getById(int userId) {
        Zuyuandengji zuyuandengji = null;
        try {
            zuyuandengji= cgBingAnMapper.qryByUserId(userId);
            if (null == zuyuandengji){
                LOGGER.debug("CgBingAnServiceImpl.getById 查询为空！！");
                System.out.println(zuyuandengji.toString());
            }else {
                LOGGER.debug("CgBingAnServiceImpl.getById 查询为空！！");
            }
        } catch (Exception e) {
            LOGGER.error("CgBingAnServiceImpl.getById 查询异常！！》》》》"+e.getMessage());
        }
        return zuyuandengji;
    }

}
